var status = -1;

function action(e, f, g) {
    if (e == 1) {
        status++
    } else {
        if (status == 0) {
            cm.dispose();
            return
        }
        status--
    }
    switch (cm.getPlayer().getMapId()) {
        case 889100100:
            if (status == 0) {
                cm.askMenu("Hello~I am Snow Spirit.#b\r\n\r\n#L0#Go to Protect Snowman - Easy (Level 10)#l\r\n#L1#Go to Protect Snowman - Medium (Level 30)#l\r\n#L2#Go to Protect Snowman - Hard (Level 70)#l")
            } else {
                if (status == 1) {
                    if (g == 0) {
                        cm.warp(889100000, 0);
                        cm.dispose()
                    } else {
                        if (g == 1) {
                            cm.warp(889100010, 0);
                            cm.dispose()
                        } else {
                            if (g == 2) {
                                cm.warp(889100020, 0);
                                cm.dispose()
                            }
                        }
                    }
                }
            }
            break;
        case 889100000:
        case 889100010:
        case 889100020:
            if (status == 0) {
                cm.askMenu("Hello~I am Snow Spirit!#b\r\n\r\n#L0#Go to Protect Snowman#l")
            } else {
                if (status == 1) {
                    var l = ((cm.getMapId() % 100) / 10) | 0;
                    var a = cm.getEventManager("Christmas");
                    if (a == null) {
                        cm.sendOk("Please try again later.");
                        cm.dispose();
                        return
                    }
                    if (cm.getPlayer().getParty() == null || !cm.isLeader()) {
                        cm.sendOk("The leader of the party must be here.")
                    } else {
                        var b = cm.getPlayer().getParty().getMembers();
                        var h = cm.getPlayer().getMapId();
                        var d = true;
                        var k = 0;
                        var c = b.iterator();
                        while (c.hasNext()) {
                            var i = c.next();
                            var j = cm.getPlayer().getMap().getCharacterById(i.getId());
                            if (j == null || j.getLevel() < (l == 0 ? 10 : (l == 1 ? 30 : 70))) {
                                d = false;
                                break
                            }
                            k++
                        }
                        if (d && k >= 2) {
                            if (a.getInstance("Christmas" + l) == null) {
                                a.startInstance(cm.getParty(), cm.getMap())
                            } else {
                                cm.sendOk("Another party quest has already entered this channel.")
                            }
                        } else {
                            cm.sendOk("All members of your party must be here.")
                        }
                    }
                    cm.dispose()
                }
            }
            break;
        case 889100001:
        case 889100011:
        case 889100021:
            if (cm.getPlayer().getEventInstance() == null || !cm.isLeader()) {
                cm.sendOk("Please, I need your leader.")
            } else {
                if (!cm.getPlayer().getEventInstance().getProperty("stage").equals("1")) {
                    cm.sendOk("Please protect the Snowman until the time runs out!")
                } else {
                    if (cm.getPlayer().getMap().countMonsterById(9400319) > 0 || cm.getPlayer().getMap().countMonsterById(9400320) > 0 || cm.getPlayer().getMap().countMonsterById(9400321) > 0) {
                        cm.sendOk("Please defeat the Cross!")
                    } else {
                        var l = ((cm.getMapId() % 100) / 10) | 0;
                        cm.givePartyExp((l == 0 ? 2500 : (l == 1 ? 7500 : 20000)));
                        cm.givePartyNX((l == 0 ? 250 : (l == 1 ? 500 : 750)));
                        cm.warpParty(cm.getMapId() + 1)
                    }
                }
            }
            cm.dispose();
            break
    }
}

function start() {
    status = -1;
    action(1, 0, 0)
};